import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

const path = require('path');

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  //base:'./',
  resolve:{
    alias:{
      "@":path.resolve(__dirname,'./src')
    }
  },
  define:{
    'process.env':{
      VUE_APP_BASE_API:'http://dikma-smart-car.dev.1plus.store'
    }
  },
  // 本地运行配置，及反向代理配置
  server: {
      //cors: true, // 默认启用并允许任何源
      //open: true, // 在服务器启动时自动在浏览器中打开应用程序
      //反向代理配置，注意rewrite写法，开始没看文档在这里踩了坑
      proxy: {
        '/api': {
          target: '',   //代理接口https://ysdemo.eeeyooo.com,http://severino.eeeyooo.com/
          changeOrigin: true,
          //rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
  },
  css: {
    preprocessorOptions: {
        scss: {
            charset: false
        }
    },
    postcss: {
        plugins: [
            {
                postcssPlugin: 'internal:charset-removal',
                AtRule: {
                    charset: (atRule) => {
                        if (atRule.name === 'charset') {
                            atRule.remove();
                        }
                    }
                }
            }
        ],
    },
  }
})
